
 /**
 * Role.java.java.
 * User: BrianChen Date: 2012-6-5 下午03:44:09
 *
 * Copyright (c) 2009 Hewlett-Packard Development Company, L.P.
 * All rights reserved.
 */
package com.collapsar.core.security.model;

import java.util.Set;

import com.collapsar.core.orm.model.VersionalEntity;

/**
 * <pre>
 * REVISIONS: 
 * Version 	Date 		Author 			Description
 * ------------------------------------------------------------------- 
 * 1.0 		2012-6-5 	BrianChen 	1. Created this class. 
 * </pre>
 * 
 * @author BrianChen
 * @date 2012-6-5 下午03:44:09
 * @version 1.0
 * @see
 * 
 */
@SuppressWarnings("serial")
public class Role extends VersionalEntity{
	private String code = null;
	private String name = null;
	private Set<Group> groups = null;
	private Set<Authority> authorities = null;
	
//	private Set<User> users = new HashSet<User>();
//	public Set<User> getUsers() {
//		return users;
//	}
//	public void setUsers(Set<User> users) {
//		this.users = users;
//	}
//	
//	public void addUser(User user){
//		this.users.add(user);
//	}
//	
//	public void deleteUser(User user){
//		this.users.remove(user);
//	}
	

	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Set<Group> getGroups() {
		return groups;
	}
	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}
	public Set<Authority> getAuthorities() {
		return authorities;
	}
	public void setAuthorities(Set<Authority> authorities) {
		this.authorities = authorities;
	}
	@Override
	public int hashCode() {
		return this.code.hashCode();
	}
	@Override
	public boolean equals(Object obj) {
		if(this == obj){
			return true;
		}
		if(!(obj instanceof Role)){
			return false;
		}
		final Role role = (Role)obj;
		if(!this.code.equals(role.getCode())){
			return false;
		}
		return true;
	}
	
	
}

